import axios from 'axios'
import NProgress from 'nprogress'

const service = axios.create({
    timeout: 2000
})

// 请求拦截器
service.interceptors.request.use(
    (config) => {
        NProgress.start()
        return config
    },
    // () => {

    // }
)

//响应拦截器
service.interceptors.response.use(
    response => {
        NProgress.done()
        return response.data
    },
    error => {
        alert('发送请求失败' + error.message)
        NProgress.done()
        return new Promise(() => { })
    }
)

export default service